import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
import { BaseEntity } from './baseentity';
import { ADesign } from './design.entity';
import { AViewScope } from './viewscope.entity';
import { AProperty } from './property.entity';

@Entity()
export class AScope extends BaseEntity {
  @Column({ nullable: false })
  name: string;

  @Column({ nullable: false })
  componentName: string;

  @Column({ nullable: true })
  parent: string;

  @ManyToOne(() => ADesign, (a) => a.scopes, { onDelete: 'CASCADE' })
  design: ADesign;

  // @ManyToMany(() => AView, (a) => a.scopes)
  // views: AView[];

  @OneToMany(() => AViewScope, (a) => a.scope, { cascade: true })
  viewscopes: AViewScope[];

  @OneToMany(() => AProperty, (a) => a.scope, { cascade: true })
  propertys: AProperty[];

  @Column({ nullable: true })
  order: number;
}
